import re

from Code.XmlDataOperation import XmlDataOperation
import pandas as pd
class XmlDataOperationXLSX(XmlDataOperation):
    def __init__(self):
        super().__init__()

    def handle_file(self, path):
        data = pd.read_excel(path)  # 读取xlsx中的第一个sheet
        classCodes = data[['ClassCode']]
        #print(classCodes)
        dataDic = {}
        for i in range(0, len(classCodes)):
            className = classCodes.iloc[i][0]
            if  re.match('^(?=.*[0-9] $ )(?=.*[a-zA-Z])', className):
                # print(className)
                if className in dataDic.keys():
                    dataDic[className] = dataDic[className] + 1
                else:
                    dataDic[className] = 1

        return dataDic